<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./vue.js"></script>
</head>

<body>
    <div id="app">
        <input type="button" value="浪起来" @click="fn1">
        <input type="button" value="停止" @click="fn2">

        <h3>{{ msg }}</h3>
    </div>

    <script>
        var vm = new Vue({
            data: {
                msg: '我拿Buff,谢谢~',
                timer: false
            },
            methods: {
                fn1() {
                    if (this.timer) clearInterval(this.timer)
                    this.timer = setInterval(() => {

                        const arr = this.msg.split('')

                        arr.push(arr.shift())

                        this.msg = arr.join('')

                    }, 200)
                },
                fn2() {
                    // console.log(this.timer);
                    clearInterval(this.timer)
                    this.timer = false
                }

            }
        }).$mount('#app')
    </script>
</body>

</html>